package com.tuliyou.dto;

import com.tuliyou.entity.Major;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 专业DTO（用于前后端交互，映射接口返回的专业信息）
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MajorDTO {

    private String majorCode; // 对应表中major_code

    private String majorName; // 对应表中major_name

    private String parentCode; // 对应表中parent_code

    private Integer level; // 对应表中level

    private String degreeType; // 对应表中degree_type

    private String years; // 对应表中years

    private String coreCourses; // 对应表中core_courses

    private String employmentDir; // 对应表中employment_dir

    public static MajorDTO fromMajor(Major major) {
        if (major == null) {
            return null;
        }
        return new MajorDTO(
                major.getMajorCode(),
                major.getMajorName(),
                major.getParentCode(),
                major.getLevel(),
                major.getDegreeType(),
                major.getYears(),
                major.getCoreCourses(),
                major.getEmploymentDir()
        );
    }
}
